home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / tex-k / tex-k-archive.past / tex-k-archive.gz / tex-k-archive / 000432_janl@math.uio.no_Sat Mar 26 00:24:37 1994.msg < prev    next >
Internet Message Format  |  1994-10-11  |  2KB

  1. Received: from pat.uio.no by cs.umb.edu with SMTP id AA16791
  2.   (5.65c/IDA-1.4.4 for <tex-k@cs.umb.edu>); Sat, 26 Mar 1994 02:12:05 -0500
  3. Received: from ulrik.uio.no by pat.uio.no with local-SMTP (PP) 
  4.           id <27443-0@pat.uio.no>; Fri, 25 Mar 1994 23:24:39 +0100
  5. Received: from mnemosyne.uio.no by smaug.uio.no ;
  6.           Fri, 25 Mar 1994 23:24:38 +0100
  7. Message-Id: <9403252224.AAsmaug27575@smaug.uio.no>
  8. To: tex-k@cs.umb.edu
  9. Reply-To: janl@math.uio.no
  10. Subject: a script to generate ls-R files
  11. Date: Fri, 25 Mar 1994 23:24:37 +0100
  12. From: Nicolai Langfeldt <janl@math.uio.no>
  13.  
  14.  
  15. As some people might have notived I'm using the external database
  16. exclusivly to cut down startup time. The reasons are a bit messy and
  17. you don't wanna know :-) Anyway, I wrote this perl script to generate
  18. ls-R files I'm much more happy with. All the network mounted fonts are
  19. in directory names starting with zz, forcing those to be scanned last
  20. and causing fonts in them that in local directories not to be listed
  21. in the database . It is of course much slower than 'ls -R' but builds
  22. a eminently desierable database :-)
  23.  
  24. So, here for you to enjoy any way you wish, no strings atached:
  25.  
  26. #!/local/bin/perl -w
  27. #
  28. # Simple script to generate a ls -R like file listing with no duplicates.
  29. # Will always prefer the first one in the path. Subdirs to the topdirs
  30. # are traversed in alphabetical order.
  31. #
  32. # - janl@math.uio.no
  33.  
  34. $topdirs = '/local/TEX/lib';    # Space separated list
  35.  
  36. %alreadyfound = ();
  37.  
  38. open(OUT,">ls-R");
  39.  
  40. foreach $t (split(' ',$topdirs)) {
  41.     &recursedir($t);
  42. }
  43.  
  44. close(OUT);
  45. exit(0);
  46.  
  47. sub recursedir {
  48.  
  49.     local($currentdir) = @_;
  50.     local(@subdirs,$d);
  51.  
  52.     @subdirs=();
  53.  
  54.     # We don't have more than one DIR open at a time so that's not local
  55.     # and if we die on this it's because of a internal error, or maybe
  56.     # someone doing work on the directories we're traversing.
  57.     opendir(DIR,$currentdir) || die;
  58.  
  59.     print OUT "$currentdir:\n";
  60.     foreach $f (readdir(DIR)) {
  61.     next if (($f eq '.') || ($f eq '..') || ($f =~ /~/));
  62.     $fn="$currentdir/$f";
  63.     stat($fn);
  64.     if (-d _) {
  65.         push(@subdirs,$fn);
  66.     } elsif ((-f _) && (!$alreadyfound{$f})) {
  67.         $alreadyfound{$f}=1;
  68.         print OUT "$f\n";
  69.     } 
  70.     }
  71.     closedir(DIR);
  72.     print OUT "\n";
  73.     foreach $d (sort(@subdirs)) {
  74.     &recursedir($d);
  75.     }
  76. }
  77.  
  78.  
  79.  
  80. --
  81. Nicolai Langfeldt, janl@math.uio.no
  82. Linux miscellanea, TeX stuff